package e.odbo.data.sample.version;

import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.serialize.DataRead;
import com.openbravo.data.loader.serialize.DataWrite;
import e.odbo.data.dao.table.I_TableSentenceBuilder;
import e.odbo.data.dao.table.TableDefinition;
import e.odbo.data.model.DataBase;
import e.odbo.data.dao.BaseDAO;

public class AppVersionDAO extends BaseDAO<AppVersion> {

    public AppVersionDAO(I_Session s, I_TableSentenceBuilder tableBuilder) {
        super(s, tableBuilder);
    }

    @Override
    public TableDefinition getTable() {
        return new TableDefinition(DataBase.versionTable);
    }

    @Override
    public void writeInsertValues(DataWrite dp, AppVersion obj) throws BasicException {
        dp.setString(1,obj.getModelName());
        dp.setString(2,obj.getVersion());
    }

    @Override
    public Class getSuportClass() {
        return AppVersion.class;
    }

    @Override
    public AppVersion readValues(DataRead dr, AppVersion obj) throws BasicException {
        if(obj==null)
            obj=new AppVersion();
        obj.setModelName(dr.getString(1));
        obj.setVersion(dr.getString(2));
        return obj;
    }
}
